import { ref, reactive, computed } from "vue";
import { defineStore } from "pinia";
import { pageEquipments } from "@/api/equipment";

export const useEquipmentStore = defineStore("equipment", () => {


  const equipmentPage = reactive({
    pageNum: 1,
    pageSize: 10,
    total: 0,
    datas: [],
  });

  const pageDTO=reactive({
    pageNum: 1,
    pageSize: 10,
    name:""
  })

  const getEquipmentPage = async () => {
    const res = await pageEquipments(pageDTO);
    const data = res.data;
    equipmentPage.pageNum = parseInt(data.pageNum);
    equipmentPage.pageSize = parseInt(data.pageSize);
    equipmentPage.total = parseInt(data.total);
    equipmentPage.datas = data.datas;
  };

  return { equipmentPage,pageDTO, getEquipmentPage };
});
